package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {
    @Autowired
    private WmMaterialService wmMaterialService;
    /**
     * 上传图片
     */
    @PostMapping("/upload_picture")
    public ResponseResult uploadPic(MultipartFile multipartFile){
        ResponseResult responseResult = wmMaterialService.uploadPic(multipartFile);
        return responseResult;
    }

    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmMaterialDto dto){
        return wmMaterialService.list(dto);
    }

    /**
     * 删除
     */
    @GetMapping("/del_picture/{id}")
    public ResponseResult del(@PathVariable Integer id){
        return wmMaterialService.del(id);
    }

    /**
     * 收藏
     */
    @GetMapping("/collect/{id}")
    public ResponseResult collect(@PathVariable Integer id){
        return wmMaterialService.collect(id);
    }
}
